from django.db import models


# Create your models here.

# 创建商品表
class Goods(models.Model):
    # 商品id
    goods_id = models.CharField(max_length=255, verbose_name="商品id")
    # 商品名称
    goods_name = models.CharField(max_length=255, verbose_name="商品名称")
    # 商品图片
    goods_img = models.CharField(max_length=855, verbose_name="商品图片", null=True)
    # 商品价格
    goods_price = models.CharField(max_length=255, verbose_name="商品价格")
    # 商品库存
    goods_stock = models.IntegerField(default=0, verbose_name="商品库存")
    # 商品销量
    goods_sales = models.IntegerField(default=0, verbose_name="商品销量")
    # 二级分类id
    goods_sid = models.CharField(max_length=255, verbose_name="二级分类id", default="", null=True, blank=True)
    # 超值爆款id
    goods_signId = models.CharField(max_length=255, verbose_name="超值爆款id", default="", null=True, blank=True)
    # 首页导航id
    goods_navId = models.CharField(max_length=255, verbose_name="首页导航id", default="", null=True, blank=True)
    # 首页推送id
    goods_pushId = models.CharField(max_length=255, verbose_name="首页推送id", default="", null=True, blank=True)

    # 配置模型元数据
    class Meta:
        ordering = ["id"]  # 根据id进行排序
        db_table = "goods"  # 创建的表名
        verbose_name = "商品表"  # 当前表的别名
        verbose_name_plural = verbose_name

    def __str__(self):
        return '%s:%s' % (self.id, self.goods_name)


# 创建商品图片表
class GoodsImg(models.Model):
    # 商品id
    goods_id = models.CharField(max_length=255, verbose_name="商品id")
    # 图片一
    goods_image_one = models.CharField(max_length=1000, verbose_name="商品id", default="", null=True, blank=True)
    # 图片二
    goods_image_two = models.CharField(max_length=1000, verbose_name="图片二", default="", null=True, blank=True)
    # 图片三
    goods_image_thr = models.CharField(max_length=1000, verbose_name="图片三", default="", null=True, blank=True)
    # 图片四
    goods_image_four = models.CharField(max_length=1000, verbose_name="图片四", default="", null=True, blank=True)
    # 图片五
    goods_image_five = models.CharField(max_length=1000, verbose_name="图片五", default="", null=True, blank=True)

    # 配置模型元数据
    class Meta:
        ordering = ["id"]  # 根据id进行排序
        db_table = "goods_image"  # 创建的表名
        verbose_name = "商品图片表"  # 当前表的别名
        verbose_name_plural = verbose_name

    def __str__(self):
        return '%s:%s' % (self.id, self.goods_image_one)


# 创建商品展示表
class GoodsShow(models.Model):
    # 商品id
    goods_id = models.CharField(max_length=255, verbose_name="商品id")
    # 图片一
    goods_show_one = models.CharField(max_length=1000, verbose_name="图片一", default="", null=True, blank=True)
    # 图片二
    goods_show_two = models.CharField(max_length=1000, verbose_name="图片二", default="", null=True, blank=True)
    # 图片三
    goods_show_thr = models.CharField(max_length=1000, verbose_name="图片三", default="", null=True, blank=True)

    # 配置模型元数据
    class Meta:
        ordering = ["id"]  # 根据id进行排序
        db_table = "goods_show"  # 创建的表名
        verbose_name = "商品展示表"  # 当前表的别名
        verbose_name_plural = verbose_name

    def __str__(self):
        return '%s:%s' % (self.id, self.goods_show_one)


# 创建商品款式表
class GoodsStyle(models.Model):
    # 商品id
    goods_id = models.CharField(max_length=255, verbose_name="商品id")
    # 款式一
    goods_style_one = models.CharField(max_length=1000, verbose_name="图片三", default="", null=True, blank=True)
    # 款式二
    goods_style_two = models.CharField(max_length=1000, verbose_name="图片三", default="", null=True, blank=True)
    # 款式三
    goods_style_thr = models.CharField(max_length=1000, verbose_name="图片三", default="", null=True, blank=True)
    # 款式四
    goods_style_four = models.CharField(max_length=1000, verbose_name="图片三", default="", null=True, blank=True)
    # 款式五
    goods_style_five = models.CharField(max_length=255, verbose_name="图片三", default="", null=True, blank=True)

    # 配置模型元数据
    class Meta:
        ordering = ["id"]  # 根据id进行排序
        db_table = "goods_style"  # 创建的表名
        verbose_name = "商品款式表"  # 当前表的别名
        verbose_name_plural = verbose_name

    def __str__(self):
        return '%s:%s' % (self.id, self.goods_style_one)


# 创建热门搜索关键词
class GoodsSeaHot(models.Model):
    # 热门关键词
    value = models.CharField(max_length=20, verbose_name="热门关键词")

    # 配置模型元数据
    class Meta:
        ordering = ["id"]  # 根据id进行排序
        db_table = "goods_search_hot"  # 创建的表名
        verbose_name = "热门搜索表"  # 当前表的别名
        verbose_name_plural = verbose_name

    def __str__(self):
        return '%s:%s' % (self.id, self.value)


# 创建商品收藏表
class GoodsCollect(models.Model):
    # 用户id
    uid = models.CharField(max_length=255, verbose_name="用户id")
    # 商品id
    gid = models.CharField(max_length=255, verbose_name="商品id")

    # 配置模型元数据
    class Meta:
        ordering = ["id"]  # 根据id进行排序
        db_table = "goods_collect"  # 创建的表名
        verbose_name = "热门搜索表"  # 当前表的别名
        verbose_name_plural = verbose_name

    def __str__(self):
        return '%s:%s' % (self.id, self.uid)


# 购物车表
class GoodsCart(models.Model):
    # 用户id
    uid = models.CharField(max_length=255, verbose_name="用户id")
    # 商品id
    gid = models.CharField(max_length=255, verbose_name="商品id")
    # 商品数量
    num = models.IntegerField(default=1, verbose_name="商品数量")

    # 配置模型元数据
    class Meta:
        ordering = ["id"]  # 根据id进行排序
        db_table = "goods_cart"  # 创建的表名
        verbose_name = "购物车列表"  # 当前表的别名
        verbose_name_plural = verbose_name

    def __str__(self):
        return '%s:%s' % (self.id, self.uid)


